package com.example.demo.controller;/**
 * Created by zhanghb on 2019/9/9.
 */


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.entity.User;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version:
 * @author:
 * @className: UserController
 * @packageName: com.fendo.mybatis.plus.controller
 * @description: 用户Controller
 * @data:
 **/
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 分页 PAGE
     */
    @RequestMapping(value = "page", method = RequestMethod.GET)
    public Object page() {
        return userService.page(new Page<User>(0,12));
    }



    /**
     * 插入 OR 修改
     */
    @RequestMapping(value = "saveOrUpdate", method = RequestMethod.POST)
    public Object saveOrUpdate(User user) {
        userService.saveOrUpdate(user);
     return 0;
    }
    /**
     * 插入 OR 修改
     */
    @RequestMapping(value = "delete", method = RequestMethod.GET)
    public Object delete(Long id) {
        boolean result   = userService.removeById(id);
        return null;
    }

}

